from selenium.webdriver.common.by import By
from Yuekao.Base.Base import Base

class Page(Base):

    # 定位器
    # 定位登录文本
    login_text = (By.LINK_TEXT,'登录')
    # 封装点击登录文本
    def click_text(self):
        self.click(self.login_text)
    # 定位账号输入框
    user_input = (By.NAME,'username')
    # 封装输入账号
    def send_user(self):
        self.send_keys(self.user_input,'15523615757')
    # 定位密码输入框
    pwd_input = (By.CSS_SELECTOR,'#theForm > div:nth-child(2) > span.register-input > input')
    # 封装输入密码
    def send_pwd(self):
        self.send_keys(self.pwd_input,'123456')
    # 定位登录按钮
    login_button = (By.CLASS_NAME,'finish-btn')
    # 封装点击登录按钮
    def click_button(self):
        self.click(self.login_button)

    # 定位搜索框
    search_input = (By.XPATH,'//*[@id="searchForm"]/div[1]/input')
    # 封装搜索框输入
    def send_search(self):
        self.send_keys(self.search_input,'手机AAAAA')
    # 定位搜索按钮
    search_button = (By.XPATH,'//*[@id="searchForm"]/div[2]/input')
    # 封装点击搜索按钮
    def click_search(self):
        self.click(self.search_button)
    # 定位商品图片
    goods_img = (By.XPATH,'/html/body/div[5]/div[2]/div[2]/div[1]/ul/li/div[1]/span/a/img')
    # 封装点击商品图片
    def click_img(self):
        self.click(self.goods_img)
    # 定位立即购买
    go_buy = (By.ID,'buy-cart')
    # 封装点击立即购买
    def click_go(self):
        self.click(self.go_buy)
    # 定位下一步
    next_button = (By.ID,'order-button')
    # 封装点击下一步
    def click_next(self):
        self.click(self.next_button)

    # 定位团购入口
    some_buy = (By.XPATH,'/html/body/div[3]/div[2]/ul/li[5]/a')
    # 封装点击团购
    def click_some(self):
        self.click(self.some_buy)
    # 定位团购商品图片
    some_img = (By.XPATH,'/html/body/div[5]/div[2]/div[2]/div[1]/ul/li[11]/div[1]/span/a/img')
    # 封装点击团购商品图片
    def click_some_img(self):
        self.click(self.some_img)